package wlmap;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.*;





public class Home

{

    private JFrame jFrame;
    private JPanel mapLabel;
    private JLabel title, map;
    private JButton  menu, close;
    private Font titleFont = new Font("微软雅黑", 1, 28);
    private Font charFont = new Font("微软雅黑", 1, 20);
    private File mapFile = new File("D://map.png");





    public Home()

    {

        init();

    }



    public void init()

    {

        jFrame = new JFrame();

        jFrame.setLayout(new BorderLayout());

        titleInit();//初始化标题栏

        mapInit();//初始化地图

        jFrame.setBounds(700, 200, 700, 600);

        JPanel buttonPanel = new JPanel();

        buttonPanel.setLayout(new FlowLayout());
   
        menu = new JButton("功能菜单");

        menu.setFont(charFont);

        menu.addMouseListener(new MouseAdapter()

        {
            public void mouseClicked(MouseEvent e)

            {

                new NormalMenu();

            }

        });

        buttonPanel.add(menu);

        close = new JButton("关闭");

        close.setFont(charFont);

        close.addMouseListener(new MouseAdapter()

        {

            @Override

            public void mouseClicked(MouseEvent e)

            {

                System.exit(0);

            }

        });

        buttonPanel.add(close);

        jFrame.add(buttonPanel, BorderLayout.SOUTH);

        jFrame.setResizable(false);

        jFrame.setVisible(true);

    }



    public void titleInit()

    {

        title = new JLabel("校园导航系统", SwingConstants.CENTER);

        title.setFont(titleFont);

        jFrame.add(title, BorderLayout.NORTH);//标题文字

    }



    public void mapInit()

    {

        ImageIcon imageIcon = new ImageIcon(mapFile.getPath());

        imageIcon.setImage(imageIcon.getImage().getScaledInstance(imageIcon.getIconWidth(),

                imageIcon.getIconHeight(), Image.SCALE_DEFAULT));

        map = new JLabel();

        map.setBounds(0, 0, 600, 500);

        map.setHorizontalAlignment(0);

        map.setIcon(imageIcon);

        mapLabel = new JPanel();

        mapLabel.setSize(690, 400);

        mapLabel.add(map);

        jFrame.add(mapLabel, BorderLayout.CENTER);//地图显示

    }
   
    public static void main(String[] args)

    {

    	Home home = new Home();

    }




}
